import 'package:boss/ui/page/login/constant/login_type.dart';
import 'package:boss/ui/page/login/model/cache_user.dart';
import 'package:flutter/material.dart';

class LoginProvider extends ChangeNotifier {
  LoginType loginType = LoginType.userPassword;
  String storeNo;
  String phone;
  String password;
  String code;

  LoginProvider() {
    var data = CacheUser.getCacheUser();

    if (data != null) {
      storeNo = data.loginUser?.storeNo;
      phone = data.loginUser?.phone;
      password=data.loginUser.passWord;
    }
  }

  toggleLoginType() {
    loginType = loginType == LoginType.userPassword
        ? LoginType.phoneCode
        : LoginType.userPassword;
    notifyListeners();
  }

  setStoreNo(String value) {
    storeNo = value;
    notifyListeners();
  }

  setPhone(String value) {
    phone = value;
    notifyListeners();
  }

  setPassword(String value) {
    password = value;
    notifyListeners();
  }

  setCode(String value) {
    code = value;
    notifyListeners();
  }
}
